﻿using Lsk.Data;
using System;
using System.Collections.Generic;
using System.Data.Entity.Core.Objects;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Lsk.Business.DTO;

namespace Lsk.Business
{
    public class Setting
    {
        private Lsk.Data.lskEntities _entity;

        public Setting()
        {
            _entity = new lskEntities();
            var _ = typeof(System.Data.Entity.SqlServer.SqlProviderServices);
            bool instanceExists = System.Data.Entity.SqlServer.SqlProviderServices.Instance != null;
        }


        public  Mobile_Settings  GetSetting()
        {
            Mobile_Settings setting = (from a in _entity.Mobile_Settings select a).FirstOrDefault();
            return setting;
        }

        public IEnumerable<GetGellery_Result> GetGallery()
        {
          ObjectResult<GetGellery_Result>  result=  _entity.GetGellery();
          return result.AsEnumerable<GetGellery_Result>();
        }

        public InitHomeMessage GetInitHomeMessage()
        {
            InitHomeMessage homeMsg = new InitHomeMessage();
            homeMsg.newsList = _entity.GetNews(3);
            homeMsg.userfulInfoList = _entity.GetUsefulInfo(3);
            homeMsg.marketProjectList = _entity.GetPropertyDirectory(4);
            homeMsg.bestBuyList = _entity.GetBestBuyAllSaleProperty(4);
            homeMsg.newSaleList = _entity.GetAllNewSaleProperty(4);
            homeMsg.auctionList = _entity.GetAuction(4);
            return homeMsg;
    }

    }
}
